package com.dindang.maintenance.mvp.model;

import android.app.Application;

import com.dindang.maintenance.mvp.model.api.service.CommonService;
import com.dindang.maintenance.mvp.model.entity.BaseResponse;
import com.dindang.maintenance.mvp.model.entity.Build;
import com.dindang.maintenance.mvp.model.entity.Repair;
import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;

import javax.inject.Inject;

import com.dindang.maintenance.mvp.contract.MaintainManagementContract;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;


@ActivityScope
public class MaintainManagementModel extends BaseModel implements MaintainManagementContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public MaintainManagementModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<BaseResponse<Repair.RepairList>> queryPageList(Repair.RepairListParam param) {
        Observable<BaseResponse<Repair.RepairList>> base = mRepositoryManager.obtainRetrofitService(CommonService.class)
                .queryPageList(param.page,
                        param.rows,
                        param.likeValue,
                        param.userId,
                        param.corpId,
                        param.bid,
                        param.status,
                        param.applyArea,
                        param.errType,
                        param.subType,
//                        param.cFrom,
                        param.createDateStart,
                        param.createDateEnd,
                        param.appointDateStart,
                        param.appointDateEnd,
                        param.completeDateStart,
                        param.completeDateEnd);
        return base;
    }

    @Override
    public Observable<BaseResponse<List<Build.Building>>> findBuilding(Build.BuildParam param) {
        Observable<BaseResponse<List<Build.Building>>> base = mRepositoryManager.obtainRetrofitService(CommonService.class)
                .findBuilding(param.isAdmin,param.cId,param.corpid);
        return base;
    }
}